import request from '@/utils/request'
export const roleSearch = () => request.get('roles/search')

export const roleAdd = roleData => {
  const { roleName, roleComment } = roleData
  return request.post('roles', { name: roleName, comment: roleComment })
}

export const roleEdit = role => {
  const { roleId, roleName, roleComment } = role
  return request.put('roles', {
    id: roleId,
    name: roleName,
    comment: roleComment
  })
}

export const roleDelete = id => request.delete(`roles/${id}`)

export const getRoleList = () => request.get('roles')

//分配菜单保存
export const saveMenuApi = parm =>
  request.post(`roles/${parm}/savePermissionRole`)

// 申请角色
export const applyRoleApi = params => request.post('/applications', params)

// 获取角色列表
export const getRoleListApi = () => request.get('/applications')

// 同意角色申请
export const passRoleApi = userRole =>
  request.post(`/applications/${userRole.userId}/pass`, userRole)

// 拒绝角色申请
export const refuseRoleApi = userRole =>
  request.post(`/applications/${userRole.userId}/refuse`, userRole)
